import 'package:fish_redux/fish_redux.dart';

//TODO replace with your own action
enum VillageAccessRobbitAction {
  action,
  updateAccessRobbit,
  refresh,
  openSettingPage,
  scanDeviceLog,
  activeDeviceVoip,
  rebootDevice,
  changeDeviceValue,
  saveDeviceValue,
  getDeviceAllVersion,
  updateDeviceVersion,
  deleteDevice,
  registerDevice,
}

class VillageAccessRobbitActionCreator {
  static Action onAction() {
    return const Action(VillageAccessRobbitAction.action);
  }

  static Action updateAccessRobbit() {
    return const Action(VillageAccessRobbitAction.updateAccessRobbit);
  }

  static Action refreshUI() {
    return const Action(VillageAccessRobbitAction.refresh);
  }

  static Action openSettingPage(int deviceId) {
    return Action(VillageAccessRobbitAction.openSettingPage, payload: deviceId);
  }

  static Action scanDeviceLog(int deviceId) {
    return Action(VillageAccessRobbitAction.scanDeviceLog, payload: deviceId);
  }

  static Action rebootDevice(String deviceNo) {
    return Action(VillageAccessRobbitAction.rebootDevice, payload: deviceNo);
  }

  static Action activeDeviceVoip(String deviceNo, int deviceId, bool status) {
    return Action(VillageAccessRobbitAction.activeDeviceVoip, payload: {
      'switchId': deviceId,
      'termId': deviceNo,
      'active': status ? 1 : 0
    });
  }

  static Action changeDeviceValue(
      String deviceNo, Map<String, dynamic> params) {
    return Action(VillageAccessRobbitAction.changeDeviceValue,
        payload: {'deviceNo': deviceNo, 'params': params});
  }

  static Action saveDeviceValue(String deviceNo) {
    return Action(VillageAccessRobbitAction.saveDeviceValue, payload: deviceNo);
  }

  static Action updateDeviceVersion(String deviceNo, int toVersionId) {
    return Action(VillageAccessRobbitAction.updateDeviceVersion,
        payload: {'versionId': toVersionId, 'deviceNo': deviceNo});
  }

  static Action getDeviceAllVersion() {
    return Action(VillageAccessRobbitAction.getDeviceAllVersion);
  }

  static Action deleteDevice(int deviceId, String deviceNo) {
    return Action(VillageAccessRobbitAction.deleteDevice,
        payload: {'switchId': deviceId, 'termId': deviceNo});
  }

    static Action registerDevice() {
    return Action(VillageAccessRobbitAction.registerDevice);
  }
}
